<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>随手快递</title>
    <link rel="stylesheet" type="text/css" href="../../myCss/commes.css" />
    <link rel="stylesheet" href="../../myCss/photoswipe.css"/>
    <link rel="stylesheet" href="../../myCss/default-skin/default-skin.css"/>
    <link rel="stylesheet" type="text/css" href="../../AUI/css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../font-awesome/css/font-awesome.min.css" />
    <style>
       .aui-list .aui-list-item-title{
            font-size: 12px;
        }
       .disc{
           text-align: center;
           padding-bottom:4px ;
           font-size:17px;
           background: #fff;

       }
       .d1{
           color: rgba(41, 179, 166, 0.95);
       }
       .aui-list textarea{
           font-size: 15px;
           font-family: 微软雅黑;
           color: #5a5a5a;
           height: 40px;
           margin: 0;
       }
       .z_photo {
           width: 100%;
           padding-bottom: 12px;
           overflow: auto;
           clear: both;
           margin: auto;
           background: #fff;
           border: 0;
       }
       /*遮罩层*/

       .z_mask {
           width: 100%;
           height: 100%;
           background: rgba(0, 0, 0, .5);
           position: fixed;
           top: 0;
           left: 0;
           z-index: 999;
           display: none;
       }

       .z_alert {
           width:70%;
           height: 100px;
           border-radius: .2rem;
           background: #fff;
           font-size:15px;
           text-align: center;
           position: absolute;
           left: 50%;
           top: 50%;
           transform: translate(-50%, -50%);
       }

       .z_alert p:nth-child(1) {
           line-height: 70px;
       }

       .z_alert p:nth-child(2) span {
           display: inline-block;
           width: 49%;
           height: 28px;
           line-height: 28px;
           float: left;
           border-top: 1px solid #ddd;
       }

       .z_sure {
           border-right: 1px solid #ddd;
       }

       #Pay div span{
           font-family: 黑体;
           font-weight: bold;
           font-size: 14px;
           color: #5d5d5d;
       }
       #Pay input{
           font-size: 13px;
           color: #656565;
       }
       .time span{
           font-size: 13px;
       }
       .time label{
           font-size: 13px;
           color: #666666;
       }
    </style>
</head>
<body style="overflow-x: hidden">
<div class="z_mask" id="m1">
    <!--弹出框-->
    <div class="z_alert">
        <span style="line-height: 66px"><div style="margin-top: 5px">是否取消订单？</div></span>
        <p>
            <span class="z_sure" id="s1">是</span>
            <span class="z_cancel">否</span>
        </p>
    </div>
</div>
<div class="z_mask" id="m11">
    <!--弹出框-->
    <div class="z_alert">
        <span style="line-height: 66px"><div style="margin-top: 5px">是否分享该订单到朋友圈？</div></span>
        <p>
            <span class="z_sure" id="s11">是</span>
            <span class="z_cancel">否</span>
        </p>
    </div>
</div>
<div class="z_mask" id="m2">
    <!--弹出框-->
    <div class="z_alert">
        <span style="line-height: 32px"><div style="margin-top: 7px">确认收货吗？<br>
            <small>（可能会货财两空喔）</small></div></span>
        <p>
            <span class="z_sure" id="s2">是</span>
            <span class="z_cancel">否</span>
        </p>
    </div>
</div>
<div class="z_mask" id="m3">
    <!--弹出框-->
    <div class="z_alert">
        <span style="line-height: 32px"><div style="margin-top: 7px">是否申请退款？<br>
            <small>(需对方审核)</small></div></span>
        <p>
            <span class="z_sure" id="s3">是</span>
            <span class="z_cancel">否</span>
        </p>
    </div>
</div>
<div class="z_mask" id="m4">
    <!--弹出框-->
    <div class="z_alert">
        <span style="line-height: 64px"><div style="margin-top: 7px">确定取消退款吗？<br></div></span>
        <p>
            <span class="z_sure" id="s4">是</span>
            <span class="z_cancel">否</span>
        </p>
    </div>
</div>
<header class="aui-bar aui-bar-nav" id="aui-header">
    <a class="aui-btn aui-pull-left" tapmode onclick="location.href='../UserManage/viewOrder.html'">
        <span class="aui-iconfont aui-icon-left"></span>
    </a>
    <div class="aui-title" >订单详情</div>
 <span class="aui-btn aui-pull-right" onclick="cancel()" id="cancel" style="display: none">取消</span> <i id="share" class="fa fa-share-alt aui-pull-right" style="display:none;margin-top:15px;margin-right:-10px"></i>
    <div class="aui-btn aui-pull-right" onclick="refund()" id="refund" style="display: none"><span >退款</span></div>
    <div class="aui-btn aui-pull-right" onclick="canRefund()" id="canRefund" style="display: none"><span >取消退款</span></div>
    <div class="aui-btn aui-pull-right" onclick="takeOver()" id="takeOver" style="display: none"><span >确认收货</span></div>
    <div class="aui-btn aui-pull-right" id="evaluate" style="display: none"><span >去评价</span></div>
</header>
<section class="aui-content" style="margin-top: 50px">
    <div class="aui-card-list-content-padded">
        <div class="disc"><span class="d1">· · · ❃ </span>
            <span style="font-family: 幼圆;">商品描述</span>
            <span class="d1"> ❃ · · ·</span>
        </div>
        <ul class="aui-list aui-form-list">
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-input">
                        <textarea placeholder="请输入商品名称" id="tradeName" readonly></textarea>
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-row aui-row-padded">
                    <div class="z_photo">
                        <div class="my-gallery" id="tradeImg">
                        </div>
                    </div>
                </div>
            </li>
        </ul>
    </div>
    <div class="aui-card-list-content-padded">
        <div class="disc"><span class="d1">· · · ❃ </span>
            <span style="font-family: 幼圆;">店铺描述</span>
            <span class="d1"> ❃ · · ·</span>
        </div>
        <ul class="aui-list aui-form-list">
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-input">
                        <textarea placeholder="请输入店铺名称" id="purchaseStore" readonly></textarea>
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-row aui-row-padded">
                    <div class="z_photo">
                        <div class="my-gallery" id="purchaseImg">
                        </div>
                    </div>
                </div>
            </li>
        </ul>
    </div>
    <div class="aui-card-list-content-padded aui-margin-b-15 aui-list-item-arrow" style="background: #fff;border-bottom: 1px solid #ddd">
        <div id="storeMap" style="margin: 0 0 10px 0;font-size: 15px;" ><span class="fa fa-map-marker" ></span><span style="margin-left: 10px"><input id="purchasePlace" style="border: 0;width: 80%" readonly></span></div>
    </div>
</section>
<!--收货地址-->
<section class="aui-content">
    <div class="aui-card-list aui-border-b">
        <div class="aui-card-list-content-padded"style="height: 80px">
        
            <div style="font-size: 14px" ><span>收货地址</span>
            <span style="float: right;font-size: 13px;color:rgb(107, 107, 107) "><span id="contacts" style="padding-right: 3px"></span> <span id="contactsPhone"></span></span><br>
                <span style="float: right;color: rgb(161, 161, 161);font-size:13px" id="address" ></span><br>
                <span style="float: right;color:rgb(161, 161, 161) ;font-size:13px" id="addressDetails" ></span>
                
            </div>
            	
                
        </div>
    </div>
</section>
<section class="aui-content" >
    <div class="aui-card-list" id="Pay">
        <div class="aui-card-list-content-padded aui-border-b aui-border-t ">
            <div style="font-size: 15px;margin-bottom: 5px">
                <span>小费</span>
                <input id="reward" style="width:80px;border:0;float: right;text-align: right;padding:3px 0px 0 0" readonly >
            </div>
        </div>
        <div class="aui-card-list-content-padded aui-border-b aui-border-t ">
            <div style="font-size: 15px;margin-bottom: 5px">
                <span>商品金额</span>
                <input id="estimateThePrice" style="width:80px;border:0;float: right;text-align: right;padding:3px 0px 0 0" readonly>
            </div>
        </div>
        <div class="aui-card-list-content-padded aui-border-b aui-border-t ">
            <div style="font-size: 13px">
                <span>快递费</span>
                <input id="courierFees" style="width:80px;border:0;float: right;text-align: right;padding:3px 0px 0 0" readonly >
            </div>
        </div>
            <div class="aui-card-list-content-padded aui-border-b aui-border-t " id="vou" style="display: none">
                <div style="font-size: 13px">
                    <span>使用代金券</span>
                    <input id="vouchersPrice" style="width:80px;border:0;float: right;text-align: right;padding:3px 0px 0 0" readonly >
                </div>
            </div>
        <div class="aui-card-list-content-padded aui-border-b aui-border-t " id="totle" style="display: none;height: 42px">
            <div  class="aui-pull-right">
                <span id="demandPayPrice"style="font-size: 15px;font-weight: bold;color: #343434" ></span>
            </div>
        </div>
    </div>
</section>
<!--时间-->
<section class="aui-content time">
    <div class="aui-card-list">
        <div class="aui-card-list-content-padded aui-border-b aui-border-t">
            <div style="font-size: 15px" > <label >下单时间</label>
                <span style="float: right" id="demandCreatetime"></span>
            </div>
        </div>
        <div class="aui-card-list-content-padded aui-border-b aui-border-t">
            <div style="font-size: 15px" > <label>期望送达时间</label>
                <span style="float: right"id="expectedArrivalTime" ></span>
            </div>
        </div>
        <div class="aui-card-list-content-padded aui-border-b aui-border-t">
            <div style="font-size: 15px" > <label >接单时间</label>
                <span style="float: right" id="acceptTime"></span>
            </div>
        </div>
    </div>
</section>
<section class="aui-content time">
    <div class="aui-card-list">
        <div class="aui-card-list-content-padded aui-border-b aui-border-t" id="purchaseUserId" onclick="viewpInfo()">
            <div style="font-size: 15px" ><label >接单人</label>
                <span style="float: right" id="purchaseName"></span>
            </div>
        </div>
        <div class="aui-card-list-content-padded aui-border-b aui-border-t" id="courierId" onclick="viewcInfo()">
            <div style="font-size: 15px" ><label>快递员</label>
                <span style="float: right" id="courierName"></span>
            </div>
        </div>
      <!--   <div class="aui-card-list-content-padded aui-border-b aui-border-t">
            <div style="font-size: 15px" > <label >预计送达时间</label>
                <span style="float: right" id="23"></span>
            </div>
        </div> -->
        <div class="aui-card-list-content-padded aui-border-b aui-border-t">
            <div style="font-size: 15px" > <label >完成时间</label>
                <span style="float: right" id="orderEndTime"></span>
            </div>
        </div>
    </div>
</section>
<!--备注-->
<section class="aui-content">
    <div class="aui-card-list">
        <div class="aui-card-list-content-padded aui-border-b aui-border-t">
            <div style="font-size: 15px" ><span class="fa fa-tag"></span><span style="margin-left: 10px">备注</span>
                <ul class="aui-list aui-form-list">
                    <li class="aui-list-item">
                        <div class="aui-list-item-inner">
                            <div class="aui-list-item-input" ><textarea id="note" style="font-size: 13px"  readonly></textarea>
                            </div>
                        </div>
                    </li>
                </ul>
            </div>

        </div>
    </div>
</section>
<!--留言板-->
<section class="aui-content" style="margin-bottom:55px">
    <div class="aui-card-list">
        <ul class="aui-list aui-list-in" style="background: #f4f4f4;padding-bottom:5px ">
            <li class="aui-list-header">
                <span class="fa fa-comment-o"> <span style="font-size: 15px;font-family: 微软雅黑">留言板</span></span>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-title">小天才：这茶好喝吗?</div>
                    <div class="aui-list-item-right">8:00</div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-title">小笨蛋<br>回复小天才：好喝</div>
                    <div class="aui-list-item-right">8:00</div>
                </div>
            </li>
        </ul>
        <div class=" aui-text-center" style="padding: 5px 0;font-size: 14px;color: #737373;background: rgba(76, 76, 76, 0.05)" onclick="location.href='messageBoard.html'">
            查看全部留言
        </div>
    </div>
</section>
<section class="aui-bar aui-bar-tab" >
    <div style="border-top:1px solid #ddd;background: #FFF;height: 45px">
        <div style="float: left;line-height: 45px;font-size: 15px;margin-left: 20px">订单当前状态：<span style="color:#ff9a07" id="orderState"></span></div>
        <div style="float: right;" ><div class="aui-btn" style="display:none;height: 45px;line-height: 45px;border-radius:0;background: #fb6f1a;color: #fff" id="goPay">去付款</div></div>
        <div style="float: right;" ><div class="aui-btn" style="display:none;height: 45px;line-height: 45px;border-radius:0;background: #27AA9E;color: #fff" id="viewRefund">查看退款详情</div></div>
    </div>
</section>
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="pswp__bg"></div>
    <div class="pswp__scroll-wrap">
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>
        <div class="pswp__ui pswp__ui--hidden">
            <div class="pswp__top-bar">
                <div class="pswp__counter"></div>
                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>
            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)"></button>
            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)"></button>
            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript" src="../../AUI/script/api.js" ></script>
<script src="../../myJs/jquery.js"></script>
<script src="../../myJs/jquery.cookie.js"></script>
<script type="text/javascript" src="../../AUI/script/aui-tab.js" ></script>
<script type="text/javascript" src="../../myJs/iscroll.js" ></script>
<script type="text/javascript" src="../../AUI/script/aui-pull-refresh.js"></script>
<script type="text/javascript" src="../../myJs/index.js" ></script>
<script type="text/javascript" src="../../AUI/script/aui-actionsheet.js" ></script>
<script src="../../myJs/photoswipe.min.js"></script>
<script src="../../myJs/photoswipe-ui-default.min.js"></script>
<script type="text/javascript">
    var initPhotoSwipeFromDOM = function(gallerySelector) {

        // parse slide data (url, title, size ...) from DOM elements
        // (children of gallerySelector)
        var parseThumbnailElements = function(el) {
            var thumbElements = el.childNodes,
                    numNodes = thumbElements.length,
                    items = [],
                    figureEl,
                    linkEl,
                    size,
                    item;

            for (var i = 0; i < numNodes; i++) {

                figureEl = thumbElements[i]; // <figure> element

                // include only element nodes
                if (figureEl.nodeType !== 1) {
                    continue;
                }

                linkEl = figureEl.children[0]; // <a> element

                size = linkEl.getAttribute('data-size').split('x');

                // create slide object
                item = {
                    src: linkEl.getAttribute('href'),
                    w: parseInt(size[0], 10),
                    h: parseInt(size[1], 10)
                };



                if (figureEl.children.length > 1) {
                    // <figcaption> content
                    item.title = figureEl.children[1].innerHTML;
                }

                if (linkEl.children.length > 0) {
                    // <img> thumbnail element, retrieving thumbnail url
                    item.msrc = linkEl.children[0].getAttribute('src');
                }

                item.el = figureEl; // save link to element for getThumbBoundsFn
                items.push(item);
            }

            return items;
        };

        // find nearest parent element
        var closest = function closest(el, fn) {
            return el && (fn(el) ? el : closest(el.parentNode, fn));
        };

        // triggers when user clicks on thumbnail
        var onThumbnailsClick = function(e) {
            e = e || window.event;
            e.preventDefault ? e.preventDefault() : e.returnValue = false;

            var eTarget = e.target || e.srcElement;

            // find root element of slide
            var clickedListItem = closest(eTarget, function(el) {
                return (el.tagName && el.tagName.toUpperCase() === 'FIGURE');
            });

            if (!clickedListItem) {
                return;
            }

            // find index of clicked item by looping through all child nodes
            // alternatively, you may define index via data- attribute
            var clickedGallery = clickedListItem.parentNode,
                    childNodes = clickedListItem.parentNode.childNodes,
                    numChildNodes = childNodes.length,
                    nodeIndex = 0,
                    index;

            for (var i = 0; i < numChildNodes; i++) {
                if (childNodes[i].nodeType !== 1) {
                    continue;
                }

                if (childNodes[i] === clickedListItem) {
                    index = nodeIndex;
                    break;
                }
                nodeIndex++;
            }



            if (index >= 0) {
                // open PhotoSwipe if valid index found
                openPhotoSwipe(index, clickedGallery);
            }
            return false;
        };

        // parse picture index and gallery index from URL (#&pid=1&gid=2)
        var photoswipeParseHash = function() {
            var hash = window.location.hash.substring(1),
                    params = {};

            if (hash.length < 5) {
                return params;
            }

            var vars = hash.split('&');
            for (var i = 0; i < vars.length; i++) {
                if (!vars[i]) {
                    continue;
                }
                var pair = vars[i].split('=');
                if (pair.length < 2) {
                    continue;
                }
                params[pair[0]] = pair[1];
            }

            if (params.gid) {
                params.gid = parseInt(params.gid, 10);
            }

            return params;
        };

        var openPhotoSwipe = function(index, galleryElement, disableAnimation, fromURL) {
            var pswpElement = document.querySelectorAll('.pswp')[0],
                    gallery,
                    options,
                    items;

            items = parseThumbnailElements(galleryElement);

            // define options (if needed)
            options = {
                // define gallery index (for URL)
                galleryUID: galleryElement.getAttribute('data-pswp-uid'),
                getThumbBoundsFn: function(index) {
                    // See Options -> getThumbBoundsFn section of documentation for more info
                    var thumbnail = items[index].el.getElementsByTagName('img')[0], // find thumbnail
                            pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
                            rect = thumbnail.getBoundingClientRect();

                    return {x: rect.left, y: rect.top + pageYScroll, w: rect.width};
                }

            };

            // PhotoSwipe opened from URL
            if (fromURL) {
                if (options.galleryPIDs) {
                    // parse real index when custom PIDs are used
                    // http://photoswipe.com/documentation/faq.html#custom-pid-in-url
                    for (var j = 0; j < items.length; j++) {
                        if (items[j].pid == index) {
                            options.index = j;
                            break;
                        }
                    }
                } else {
                    // in URL indexes start from 1
                    options.index = parseInt(index, 10) - 1;
                }
            } else {
                options.index = parseInt(index, 10);
            }

            // exit if index not found
            if (isNaN(options.index)) {
                return;
            }

            if (disableAnimation) {
                options.showAnimationDuration = 0;
            }

            // Pass data to PhotoSwipe and initialize it
            gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
            gallery.init();
        };

        // loop through all gallery elements and bind events
        var galleryElements = document.querySelectorAll(gallerySelector);

        for (var i = 0, l = galleryElements.length; i < l; i++) {
            galleryElements[i].setAttribute('data-pswp-uid', i + 1);
            galleryElements[i].onclick = onThumbnailsClick;
        }

        // Parse URL and open gallery if it contains #&pid=3&gid=1
        var hashData = photoswipeParseHash();
        if (hashData.pid && hashData.gid) {
            openPhotoSwipe(hashData.pid, galleryElements[ hashData.gid - 1 ], true, true);
        }
    };

    // execute above function
    initPhotoSwipeFromDOM('.my-gallery');
</script>
<script type="text/javascript">
    apiready = function(){
        api.parseTapmode();
    }
 /*  var data = {
     "code": 200,
     "msg": {
         "userId": 1,
         "demandState":1,
         "orderState":3,
         "orderId":3,
         "nickname": "summery",
         "headPortraitUrl": "../../myImage/5.png",
         "creditScore": 90,
         "tradeName": "抹茶星冰乐",
         "imageUrl": ["../../myImage/g1.jpg","../../myImage/g1.jpg","../../myImage/g1.jpg","../../myImage/g1.jpg","../../myImage/g1.jpg"],
         "purchaseImg": ["../../myImage/g2.jpg","../../myImage/g2.jpg"],
         "address": "钱江湾生活区",
         "address_details": "34幢111",
         "purchaseStore": "星巴克",
         "contacts": "大佬",
         "contactsPhone": "17827384738",
         "reward": "10元",
         "estimateThePrice": "13元",
         "courierFees": "5元",
         "vouchersPrice": "15元",
         "demandPayPrice":"13元",
         "demandCreatetime": "2017-7-2 11:00",
         "expectedArrivalTime": "2017-7-2 12:10",
         "acceptTime": "2017-7-2 11:20",
         "orderEndTime": "2017-7-2 11:40",
         "purchaseName":"hahaha",
         "courierName": "小太阳",
         "purchaseAddress": "宝龙负一楼一点点",
         "note":"要小姐姐接单",
         "addressLongitude":120.391628,
         "addressLatitude":30.312482,
         "purchaseLongitude":120.391628,
         "purchaseLatitude":30.312482,
         "storeLongitude":120.328206,
         "storeLatitude":30.309771,
         "purchasePlace":"星巴克咖啡(下沙龙湖店)"
     }
 } */
 var demandId,orderId;
 var purchaseUserId,courierId;
    $(function(){
    	demandId = sessionStorage.getItem("demandId");
           $.ajax({
         type: "post",
         url: '/randomdelivery/userDemandController/releaseMessage',
         data: {
         "demandId": demandId
         },
         datatype: "json",
         success: function (data) {
        	 alert(JSON.stringify(data));
        	 sessionStorage.setItem("status",0);
        	 sessionStorage.setItem("orderId",data.msg.orderId);
        	 orderId = data.msg.orderId;
        	 orderDetail(data);
         }

         });
       /*  sessionStorage.setItem("orderId",data.msg.orderId);
        orderDetail(data); */
    })
    function orderDetail(data){
        //alert(data.msg.nickname);
        var data = data.msg;
        if(data.demandState==0){
            $("#cancel").css("display","block");
            $("#share").show();
            $("#orderState").html("未接单");
        } if(data.demandState==2){
        	$("#vou").show();
            $("#totle").show();
        	 (data.vouchersPrice==null?$("#vouchersPrice").val("未使用"):$("#vouchersPrice").val("-" + data.vouchersPrice+"元"));
             $("#demandPayPrice").html("合计：" + data.demandPayPrice+"元");
            $("#orderState").html("已评价");
        }
        else {
            if (data.orderState == 0) {
                $("#cancel").css("display", "block");
                $("#orderState").html("等待代购者确认金额");
            }
            else if (data.orderState == 1) {
                $("#goPay").show();
                $("#cancel").css("display", "block");
                $("#orderState").html("待支付");
            }
            else if (data.orderState == 2) {
                $("#vou").show();
                $("#totle").show();
                (data.vouchersPrice==null?$("#vouchersPrice").val("未使用"):$("#vouchersPrice").val("-" + data.vouchersPrice+"元"));
                $("#demandPayPrice").html("合计：" + data.demandPayPrice+"元");
                $("#refund").css("display", "block");
                $("#orderState").html("已支付");
            }
            else if (data.orderState == 3) {
                $("#vou").show();
                $("#totle").show();
                (data.vouchersPrice==null?$("#vouchersPrice").val("未使用"):$("#vouchersPrice").val("-" + data.vouchersPrice+"元")); 
                $("#demandPayPrice").html("合计：" + data.demandPayPrice+"元");
                $("#orderState").html("寄件中" +" <span class='fa fa-map-marker' onclick=\'location.href=\"../map/viewMap.html\"\'></span>");
            }
            else if (data.orderState == 4) {
                $("#vou").show();
                $("#totle").show();
                (data.vouchersPrice==null?$("#vouchersPrice").val("未使用"):$("#vouchersPrice").val("-" + data.vouchersPrice+"元")); 
                $("#demandPayPrice").html("合计：" + data.demandPayPrice+"元");
                $("#orderState").html("待取件" +" <span class='fa fa-map-marker' onclick=\'location.href=\"../map/viewMap.html\"\'></span>");
            }
            else if (data.orderState == 5) {
                $("#takeOver").show();
                $("#vou").show();
                $("#totle").show();
                (data.vouchersPrice==null?$("#vouchersPrice").val("未使用"):$("#vouchersPrice").val("-" + data.vouchersPrice+"元"));
                $("#demandPayPrice").html("合计：" + data.demandPayPrice+"元");
                $("#orderState").html("派件中" +" <span class='fa fa-map-marker' onclick=\'location.href=\"../map/viewMap.html\"\'></span>");
            }
           /*  else if (data.orderState == 6) {
                $("#takeOver").show();
                $("#vou").show();
                $("#totle").show();
                $("#vouchersPrice").val("-" + data.vouchersPrice);
                $("#demandPayPrice").html("合计：" + data.demandPayPrice);

                $("#orderState").html("已完成");
            } */
            else if (data.orderState == 6){
            	 $("#evaluate").show();
                $("#vou").show();
                $("#totle").show();
                (data.vouchersPrice==null?$("#vouchersPrice").val("未使用"):$("#vouchersPrice").val("-" + data.vouchersPrice+"元")); 
                $("#demandPayPrice").html("合计：" + data.demandPayPrice+"元");
                $("#orderState").html("已完成");
            }
            else if (data.orderState == 7) {
                $("#orderState").html("已关闭");
            }
            else if (data.orderState == 8) {
                $("#vou").show();
                $("#totle").show();
                (data.vouchersPrice==null?$("#vouchersPrice").val("未使用"):$("#vouchersPrice").val("-" + data.vouchersPrice+"元"));
                $("#demandPayPrice").html("合计：" + data.demandPayPrice+"元");
                $("#viewRefund").show();
                $("#canRefund").show();
                $("#orderState").html("退款中");
            }
            else if (data.orderState == 9) {
                //$("#evaluate").show();
                $("#vou").show();
                $("#totle").show();
                (data.vouchersPrice==null?$("#vouchersPrice").val("未使用"):$("#vouchersPrice").val("-" + data.vouchersPrice+"元"));
                $("#demandPayPrice").html("合计：" + data.demandPayPrice+"元");

                $("#orderState").html("已评价");
            }
        }
        $("#nickname").html(data.nickname);
        $("#headImg").attr("src",data.headPortraitUrl);
        $("#creditScore").html(data.creditScore);
        $("#tradeName").html(data.tradeName);
        $.each(data.tradeUrlArrayList,function(num,data){
            $("#tradeImg").append(' <figure>\
                <a href="'+data+'" data-size="800x1142">\
                <img style="width: 60px;height:60px;" src="'+data+'" >\
                </a>\
                </figure>');
        })
       
        $("#purchaseStore").html(data.purchaseStore);
        $.each(data.storeUrlArrayList,function(num,data) {
            $("#purchaseImg").append(' <figure>\
                <a href="' + data + '" data-size="800x1142">\
                <img style="width: 60px;height:60px;" src="' + data + '" >\
                </a>\
                </figure>');
        })
        $("#address").html(data.address);
        $("#addressDetails").html(data.addressDetails);
        $("#contacts").html(data.contacts);
        $("#contactsPhone").html(data.contactsPhone);
        $("#reward").val(data.reward);
        $("#courierFees").val(data.courierFees);
        $("#estimateThePrice").val(data.estimateThePrice);
        $("#demandCreatetime").html(data.demandCreatetime);
        (data.purchasePlace==""?$("#purchasePlace").val("就近购买"):$("#purchasePlace").val(data.purchasePlace));
        (data.acceptTime==null?$("#acceptTime").html("暂无"):$("#acceptTime").html(data.acceptTime));
        $("#expectedArrivalTime").html(data.expectedArrivalTime);
        (data.orderEndTime==null?$("#orderEndTime").html("订单未完成"):$("#orderEndTime").html(data.orderEndTime));
        (data.purchaseName==null?$("#purchaseName").html("暂无"):$("#purchaseName").html(data.purchaseName));
        (data.courierName==null?$("#courierName").html("暂无"):$("#courierName").html(data.courierName));
        purchaseUserId = data.purchaseUserId;
        courierId =data.courierId;
        $("#note").val(data.note);
        sessionStorage.setItem("addressLongitude",data.addressLongitude);
        sessionStorage.setItem("addressLatitude",data.addressLatitude);
        sessionStorage.setItem("purchaseLongitude",data.purchaseLongitude);
        sessionStorage.setItem("purchaseLatitude",data.purchaseLatitude);
        sessionStorage.setItem("purchasePlace",data.purchasePlace);
        sessionStorage.setItem("addr",data.address+data.addressDetails);


    }
    /*查看店铺定位*/
    $("#storeMap").on("click",function(){
        location.href="../map/storeMap.html";
    })
    $(".z_cancel").on("click",function(){
        var status = $("#statusBtn").html();
        $(".z_mask").hide();

    })
    function cancel(){
        $("#m1").show();
    }
    $("#s1").on("click",function(){
    	
    	
         $.ajax({
         type: "post",
         url: '/randomdelivery/userDemandController/cancelOrder',
         data: {
        	 orderId:orderId
         },
         datatype: "json",
         success: function (data) {
        	 alert(JSON.stringify(data));
        	 location.reload();
         }

         });


        $("#m1").hide();
    })

    /*确认收货*/
    function takeOver(){
        $("#m2").show();
    }
    $("#s2").on("click",function(){
    	
    	var orderId = sessionStorage.getItem("orderId");
         $.ajax({
         type: "post",
         url: '/randomdelivery/userDemandController/received',
         data: {
         "orderId": orderId
         },
         datatype: "json",
         success: function (data) {
        	 alert(JSON.stringify(data));
        	/*  $("#m2").hide();
             $("#evaluate").show();
             $("#orderState").html("已完成");
             $("#takeOver").hide(); */
        	 location.reload();
         }
         });
       
    })

    $("#evaluate").on("click",function(){
        location.href='evaluate.html';
    })
    $("#goPay").on("click",function(){
    	
        location.href='pay.html';
    })
    /*申请退款*/
    function refund(){
        $("#m3").show();
    }
    $("#s3").on("click",function(){
    
       location.href="refund.html";
    })
    /*取消退款*/
    function canRefund(){
        $("#m4").show();
    }
    $("#s4").on("click",function(){
        /*  $.ajax({
         type: "post",
         url: '',
         data: {
         "userId": userId
         },
         datatype: "json",
         success: function (data) {
         }
         });*/
        window.location.reload();
    })
    $("#viewRefund").on("click",function(){
        location.href="viewRefund.html";
    })
    
    $("#share").on("click",function(){
    	  $("#m11").show();
    })
    $("#s11").on("click",function(){
    	  location.href="../find/friendCircle.html";
    })
    
    
    function viewpInfo(){
    	 sessionStorage.setItem("userId",purchaseUserId);
    	location.href="../find/friendInfo.html";
    }
    function viewcInfo(){
        sessionStorage.setItem("user",courierId);
   	location.href="../find/friendInfo.html";
   }
</script>
</body>
</html>